using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace MyMvc.Model.Models.Mapping
{
    public class RelationMap : EntityTypeConfiguration<Relation>
    {
        public RelationMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Adress)
                .IsRequired()
                .HasMaxLength(1024);

            this.Property(t => t.Telephone1)
                .IsRequired()
                .HasMaxLength(80);

            this.Property(t => t.Telephone2)
                .HasMaxLength(80);

            this.Property(t => t.Fax1)
                .HasMaxLength(80);

            this.Property(t => t.Fax2)
                .HasMaxLength(80);

            this.Property(t => t.Website1)
                .HasMaxLength(1024);

            this.Property(t => t.Website2)
                .HasMaxLength(1024);

            this.Property(t => t.Mail1)
                .HasMaxLength(1024);

            this.Property(t => t.Mail2)
                .HasMaxLength(1024);

            // Table & Column Mappings
            this.ToTable("Relation");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Adress).HasColumnName("Adress");
            this.Property(t => t.Telephone1).HasColumnName("Telephone1");
            this.Property(t => t.Telephone2).HasColumnName("Telephone2");
            this.Property(t => t.Fax1).HasColumnName("Fax1");
            this.Property(t => t.Fax2).HasColumnName("Fax2");
            this.Property(t => t.Website1).HasColumnName("Website1");
            this.Property(t => t.Website2).HasColumnName("Website2");
            this.Property(t => t.Mail1).HasColumnName("Mail1");
            this.Property(t => t.Mail2).HasColumnName("Mail2");
        }
    }
}
